package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.ConfigExpressBO;
import com.cskaoyan.bean.bo.ConfigMallBO;
import com.cskaoyan.bean.bo.ConfigOrderBO;
import com.cskaoyan.bean.bo.ConfigWxBO;
import com.cskaoyan.service.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author Tang_XueCheng
 * @description 后台-配置管理模块
 * @since 2022/04/06 16:37
 */
@RestController
@RequestMapping("admin/config")
public class ConfigurationController  {

    @Autowired
    ConfigurationService configurationService;

    // 商场配置：/admin/config/mall ----------------------------------
    /**
    *@Author:TangXueCheng
    *@Description:
    *@Param:
    *@Date: "data":{"market_mall_longitude":"31°22'",
      "market_mall_latitude":"115°05'",
      "market_mall_address":"武汉",
      "market_mall_qq":"88888888",
      "market_mall_phone":"13888888888",
      "market_mall_name":"大鸟转转转"},"errmsg":"成功"
    */
    @GetMapping("mall")
    public BaseRespVo mall() {

        ConfigMallBO configMallBO = configurationService.queryConfigMall();

        return BaseRespVo.ok(configMallBO);
    }
    @PostMapping("mall")
    public BaseRespVo mall(@RequestBody @Validated ConfigMallBO configMallBO) {

        configurationService.updateConfigMallBO(configMallBO);

        return BaseRespVo.ok();
    }

    // 运费配置：/admin/config/express ------------------------------------
    /**
    *@Author:TangXueCheng
    *@Description:
    *@Param:
    *@Date:  "data":{"market_express_freight_min":"100",
     * "market_express_freight_value":"5"}
    */
    @GetMapping("express")
    public BaseRespVo express() {

        ConfigExpressBO configExpressBO = configurationService.queryExpress();

        return BaseRespVo.ok(configExpressBO);
    }
    @PostMapping("express")
    public BaseRespVo express(@RequestBody @Validated ConfigExpressBO configExpressBO) {

        configurationService.updateConfigExpressBO(configExpressBO);

        return BaseRespVo.ok();
    }

    // 订单配置：/admin/config/order ------------------------------------
    /**
    *@Author:TangXueCheng
    *@Description:
    *@Param:
    *@Date:  "data":{"market_order_unconfirm":"15",
     * "market_order_unpaid":"45",
     * "market_order_comment":"7"}
    */
    @GetMapping("order")
    public BaseRespVo order() {

        ConfigOrderBO configOrderBO = configurationService.queryOrder();

        return BaseRespVo.ok(configOrderBO);
    }
    @PostMapping("order")
    public BaseRespVo order(@RequestBody @Validated ConfigOrderBO configOrderBO) {

        configurationService.updateConfigOrderBO(configOrderBO);

        return BaseRespVo.ok();
    }

    // 小程序配置：http://182.92.235.201/static/js/chunk-2e02ed56.02f91839.js ------------------------------------
    /**
    *@Author:TangXueCheng
    *@Description:
    *@Param:
    *@Date: market_wx_catlog_goods: "四"
         * market_wx_catlog_list: "2"
         * market_wx_index_brand: "1"
         * market_wx_index_hot: "1"
         * market_wx_index_new: "1"
         * market_wx_index_topic: "2"
         * market_wx_share: "false"
    */
    @GetMapping("wx")
    public BaseRespVo wx() {

        ConfigWxBO configWxBO = configurationService.queryWx();

        return BaseRespVo.ok(configWxBO);
    }
    @PostMapping("wx")
    public BaseRespVo wx(@RequestBody @Validated ConfigWxBO configWxBO) {

        configurationService.updateConfigWxBO(configWxBO);

        return BaseRespVo.ok();
    }


}
